<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\creative;

use app\model\ZcTaskModel;
use app\service\BaseService;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Model;

class TaskService extends BaseService
{
    /**
     * @var array 任务模型列表
     */
    protected static array $zcTaskList;

    /**
     * 获取任务信息.
     *
     * @param int $id 任务id
     * @return null|array|mixed|Model|ZcTaskModel
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public static function getTaskById(int $id = 0)
    {
        if (! isset(self::$zcTaskList[$id])) {
            self::$zcTaskList[$id] = (new ZcTaskModel())->where('id', $id)->find();
        }
        return self::$zcTaskList[$id];
    }
}
